#!/bin/bash

# 设置变量
IMAGE_NAME="bmds"
IMAGE_TAG="centos7.9.2009-for-nginx-bianyi-v1.0"
DOCKERFILE_PATH="./Dockerfile"
BUILD_CONTEXT="./"

# 构建 Docker 镜像

docker build -t $IMAGE_NAME:$IMAGE_TAG -f $DOCKERFILE_PATH $BUILD_CONTEXT

# 推送镜像到镜像仓库（可选）
registry_url="registry.cn-hangzhou.aliyuncs.com"
username="chaoren3***"
password="baimei***"
docker login $registry_url -u $username -p $password


docker tag $IMAGE_NAME:$IMAGE_TAG registry.cn-hangzhou.aliyuncs.com/baimeidashu/$IMAGE_NAME:$IMAGE_TAG
docker push registry.cn-hangzhou.aliyuncs.com/baimeidashu/$IMAGE_NAME:$IMAGE_TAG



# 输出构建完成信息
echo "registry.cn-hangzhou.aliyuncs.com/baimeidashu/$IMAGE_NAME:$IMAGE_TAG   built successfully."
